package com.common.www.bean.entity.programme;


import org.springframework.boot.base.jpa.domain.annotations.QueryCacheable;
import org.springframework.boot.base.jpa.domain.entity.NumberIdentityEntity;
import com.common.www.bean.entity.project.BiddingCompany;
import com.common.www.bean.entity.project.Project;
import com.common.www.bean.entity.project.SupplyCompany;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import lombok.*;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import java.math.BigDecimal;

/**
 * 基础用需对应清单详情
 *
 * @param
 * @author andyliu
 * @date 5/28/2018 4:23 PM
 * @return
 */
@DynamicUpdate(true)
@DynamicInsert(true)
@Entity
@Getter
@Setter
@QueryCacheable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Table()
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "基础用需对应清单详情")
public class BasisDemandDetails extends NumberIdentityEntity {
    /**
     * 对应基础用需
     */
    @JsonIgnoreProperties(value = {"demandDetails"})
    @ManyToOne()
    private BasisDemand basisDemand;
    /**
     * 归属项目和公司 (标底、实施标底时无供应商)
     */
    @JsonIgnoreProperties(value = {""})
    @ManyToOne()
    private SupplyCompany supplyCompany;
    /**
     * 外线做法
     * 1.架空线（单电源）/2.架空线（双电源）/3.架空线（多电源）/4.电缆埋地+架空线（单电源）
     * /5.电缆埋地+架空线（双电源）/6.电缆埋地+架空线（多电源）/7.电缆埋地（单电源）/
     * 8.电缆埋地（双电源）/9.电缆埋地（多电源）
     */
    @Column(length = 11)
    private Integer wxzf;
    /**
     * 外线电缆材质
     * 1.铜芯电缆/2.铝芯电缆
     */
    @Column(length = 11)
    private Integer wxdlcz;
    /**
     * 外线总单价 （元/m）
     */
    @Column(length = 11, precision = 12, scale = 4)
    private BigDecimal wxzdj;
    /**
     * 内线电缆材质
     */
    @Column(length = 256)
    private String nxdlcz;
    /**
     * 总装机容量（kva）
     */
    @Column(length = 11, precision = 12, scale = 4)
    private Double zzjrl;
    /**
     * 充电桩容量比例
     */
    @Column(length = 11, precision = 12, scale = 4)
    private Double cdzrlylbl;
    /**
     * 充电桩实配比例
     */
    @Column(length = 11, precision = 12, scale = 4)
    private Double cdzdbxssbl;
    /**
     * 充电桩实配深度
     * 1.仅变压器预留容量/2.仅变压器预留容量/3.仅低压柜预留容量/4.充电桩配电总箱/5.充电桩电表箱(不挂表)/6.充电桩电表箱(挂表)
     */
    @Column(length = 11)
    private Integer cdzpjsd;
    /**
     * 内线总建面单方 （元/m2）
     */
    @Column(length = 11, precision = 12, scale = 4)
    private BigDecimal nxzjmdf;
    /**
     * 内线负荷单方（元/kva)
     */
    @Column(length = 11, precision = 12, scale = 4)
    private BigDecimal nxfhdf;
    /**
     * 数据状态:招标标底  定标数据  落地方案-标底  落地方案-定标数据
     * (参加阶段；1.标底 2.回标1 3.回标2 4.回标3 5.回标4 6.定标 7.实施标底 8.实施定标)
     */
    @Column(length = 11)
    private Integer jieDuan;


    public String getWxzfName() {
        if (wxzf == null) {
            return "/";
        }
        switch (wxzf) {
            case 1:
                return "架空线（单电源）";
            case 2:
                return "架空线（双电源）";
            case 3:
                return "架空线（多电源）";
            case 4:
                return "电缆埋地+架空线（单电源）";
            case 5:
                return "电缆埋地+架空线（双电源）";
            case 6:
                return "电缆埋地+架空线（多电源）";
            case 7:
                return "电缆埋地（单电源）";
            case 8:
                return "电缆埋地（双电源）";
            case 9:
                return "电缆埋地（多电源）";
        }
        return "/";
    }
    public String getCdzpjsdName() {
        if (cdzpjsd == null) {
            return "/";
        }
        switch (cdzpjsd) {
            case 1:
                return "仅变压器预留容量";
            case 2:
                return "仅变压器预留容量";
            case 3:
                return "仅低压柜预留容量";
            case 4:
                return "充电桩配电总箱";
            case 5:
                return "充电桩电表箱(不挂表)";
            case 6:
                return "充电桩电表箱(挂表)";
        }
        return "/";
    }

    public String getWxdlczName() {
        if (wxdlcz == null) {
            return "";
        }
        switch (wxdlcz) {
            case 1:
                return "铜芯电缆";
            case 2:
                return "铝芯电缆";
        }
        return "/";
    }

    public String getJieDuanName() {
        if (jieDuan == null) {
            return "";
        }
        switch (jieDuan) {
            case 1:
                return "招标标底";
            case 6:
                return "定标数据";
            case 7:
                return "落地方案-标底";
            case 8:
                return "落地方案-定标数据";
        }
        return "";
    }


}